<style lang="sass" scoped>
    .common_block{
        .head{
            .pink{
                color:pink;
            }
            i{
                font-size: 16px;
                margin-left: 6px;
                margin-right: 0;
            }
        }
    }
    .add{
        width: 100%;
        height:60px;
        line-height:60px;
        background: #409EFF;
        margin-top:10px;
        margin-bottom:10px;
        color:#fff;
        text-align: center;
        cursor: pointer;
    }
    .iconfont{
        font-size:25px;
        cursor:pointer;
        text-decoration:none;
        color:#666;
    }
</style>
<template>
    <div class="container pd15">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="180px" class="demo-ruleForm">
            <el-form-item label="分销商名称：" prop="companyName">
                <el-input v-model.trim="ruleForm.companyName"></el-input>
            </el-form-item>
            <el-form-item label="联系人：" prop="contact">
                <el-input v-model.trim="ruleForm.contact"></el-input>
            </el-form-item>
            <el-form-item label="联系人电话：" prop="contactPhone">
                <el-input v-model.trim="ruleForm.contactPhone"></el-input>
            </el-form-item>
            <el-form-item label="银行：" prop="bank">
                <el-input v-model.trim="ruleForm.bank"></el-input>
            </el-form-item>
            <el-form-item label="银行卡号：" prop="bankNo">
                <el-input v-model.trim="ruleForm.bankNo"></el-input>
            </el-form-item>
            <el-form-item label="纳税人识别号：" prop="taxIdNumber">
                <el-input v-model.trim="ruleForm.taxIdNumber"></el-input>
            </el-form-item>
            <el-form-item label="地址：" prop="address">
                <el-input v-model.trim="ruleForm.address"></el-input>
            </el-form-item>
            <el-form-item label="提成比例：" prop="commissionRate">
                <el-input v-model.trim="ruleForm.commissionRate" style="width:100px"></el-input> %
            </el-form-item>
            <el-form-item label="登录账号：" prop="account">
                <el-input v-model.trim="ruleForm.account"></el-input>
            </el-form-item>
            <el-form-item label="登录密码：" prop="pwd">
                <el-input v-model.trim="ruleForm.pwd" type="password"></el-input>
            </el-form-item>
            <el-form-item label="">
                <el-button @click="add('ruleForm')" v-if="!$route.query.itemCode" class="ml20" type="primary" :plain="false" round>提交</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>
<script>
    export default {
        components: {
        },
        data() {
            return {
                ruleForm: {
                    companyName:'',//	是	string	分销商名称
                    contact:'',//	是	string	联系人
                    contactPhone:'',//	是	string	联系人电话
                    bank:'',//	是	string	银行
                    bankNo:'',//	是	string	银行卡号
                    taxIdNumber:'',//	是	string	纳税人识别号
                    address:'',//	是	string	地址
                    commissionRate:'',//	是	string	提成比例
                    account:'', //	是	string	登录账号
                    pwd:'', //	是	string	登录密码
                },
                rules: {
                    companyName: [
                        { required: true, message: '请输入分销商名称', trigger: 'blur' },
                    ],
                    contact: [
                        { required: true, message: '请输入联系人', trigger: 'blur' },
                    ],
                    contactPhone: [
                        { required: true, message: '请输入联系人电话', trigger: 'blur' },
                    ],
                    bank: [
                        { required: true, message: '请输入银行', trigger: 'blur' },
                    ],
                    bankNo: [
                        { required: true, message: '请输入银行卡号', trigger: 'blur' },
                    ],
                    taxIdNumber: [
                        { required: true, message: '请输入纳税人识别号', trigger: 'blur' },
                    ],
                    address: [
                        { required: true, message: '请输入地址', trigger: 'blur' },
                    ],
                    commissionRate: [
                        { required: true, message: '请输入提成比例', trigger: 'blur' },
                    ],
                    
                    account: [
                        { required: true, message: '请输入登录账号', trigger: 'blur' },
                    ],
                    pwd: [
                        { required: true, message: '请输入登录密码', trigger: 'blur' },
                    ],
                    
                },
            }
        },
        watch: {},
        created() {

        },
        mounted() {
            this.$nextTick(() => { 
                
            });
        },
        methods: {
            add(formName){
                this.$refs[formName].validate((valid) => {
                    let param = JSON.parse(JSON.stringify(this.ruleForm));
                    if (valid) {
                        util.ajax({
                            url:config.baseApi + 'bookMall-admin/api/company/addCompany',
                            data:param,
                            success:()=>{
                                popup.miss({content:'新增成功'});
                                router.go(-1)
                            }
                        })
                    }
                })
            },
        }
    };
</script>